from django.shortcuts import render
from .sers import *
from rest_framework.viewsets import ModelViewSet
from rest_framework.authentication import TokenAuthentication
from rest_framework.permissions import IsAuthenticated,IsAdminUser
from .other import *


class BookViewSet(ModelViewSet):
    queryset = Book.objects.all()
    serializer_class = BookSerializer
    permission_classes=[MyAdminPermission]  #自定义权限
    # permission_classes = [IsAdminUser]      #只有管理员可以查看   is_staff=1 可以查看 is_staff=0 不可查看
    # permission_classes = [IsAuthenticated]
    authentication_classes = [TokenAuthentication]